
var displayDetails = function (orderId) {
	var obj_tr = document.getElementById(orderId);
	if (obj_tr.style.display == "block") {
		obj_tr.style.display = "none";
	} else {
		obj_tr.style.display = "block";
	}
};
var changeStatus = function (orderId) {
	if (confirm("\u786e\u8ba4\u8ba2\u5355\u8fdb\u5165\u9080\u8bf7\u72b6\u6001\uff0c\u4e00\u65e6\u8ba2\u5355\u8fdb\u5165\u9080\u8bf7\u72b6\u6001\uff0c\u4fbf\u4e0d\u80fd\u518d\u4fee\u6539\u548c\u5220\u9664")) {
		jtool.goto(context_path + "/order/changeOrderStatus.do?id=" + orderId);
	}
};
var deleteOrder = function (orderId) {
	jtool.goto(context_path + "/order/deleteOrder.do?id=" + orderId);
};
var editOrder = function (orderId) {
	jtool.goto(context_path + "/order/preEditOrder.do?id=" + orderId);
};
var selectProduct = function (orderId) {
	jtool.goto(context_path + "/order/selectProduct.do?orderId=" + orderId);
};
var preTakePartInOrder = function (orderId, productId) {
	jtool.goto(context_path + "/order/preTakePartInOrder.do?order.id=" + orderId + "&productId=" + productId);
};
function joinAsVendor(orderId) {
	jtool.goto(context_path + "/order/joinAsVendor.do?orderId=" + orderId);
}
function cancelOrderRequest(id) {
	jtool.goto(context_path + "/order/cancelOrderRequest.do?id=" + id);
}
function changeOrderStatus(id) {
	jtool.goto(context_path + "/order/changeOrderStatus.do?id=" + id);
}
function voteOrder(id) {
	jtool.goto(context_path + "/order/voteOrder.do?id=" + id);
}
function viewOrderVote(id) {
	jtool.goto(context_path + "/order/viewOrderVote.do?id=" + id);
}
function viewCustomerAddress(orderId, customerId, vendorId) {
	jtool.openPage(context_path + "/order/viewCustomerAddress.do?orderId=" + orderId + "&customerId=" + customerId + "&vendorId=" + vendorId);
}
function editOrderQuote(label) {
	var tr = $(label).parent().parent();
	tr.find(".amount_input").show();
	tr.find(".amount_show").hide();
	tr.find(".action_button").hide();
	tr.find(".edit_button").show();
}
function cancelQuote(label) {
	var tr = $(label).parent().parent();
	tr.find(".amount_input").hide();
	if (tr.attr("quoted") == "true") {
		tr.find(".amount_show").show();
	}
	tr.find(".edit_button").hide();
	tr.find(".action_button").show();
}
function saveOrderQuote(okInput, quoteId) {
	var tr = $(okInput).parent().parent();
	var amount = tr.find("input[name=amount]").val();
	if (amount == null || amount == "") {
		alert("\u8bf7\u8f93\u5165\u62a5\u4ef7!");
		return;
	}
	var carriage = tr.find("input[name=carriage]").val();
	if (carriage == null || carriage == "") {
		alert("\u8bf7\u8f93\u5165\u8fd0\u8d39!");
		return;
	}
	tr.find(".amount_input").hide();
	tr.find(".edit_button").hide();
	tr.find(".amount_show").show();
	tr.find("span[name=amount]").text(amount).show();
	tr.find("span[name=carriage]").text(carriage).show();
	$.ajax({url:context_path + "/order/setQuoteInfo.do", type:"POST", data:({"quoteId":quoteId, "amount":amount, "carriage":carriage}), success:function (responseMsg) {
		tr.find(".action_button").text("\u4fee\u6539").show();
		tr.attr("quoted", "true");
	}});
}

